package com.atguigu.phoenix;

import org.apache.phoenix.queryserver.client.ThinClientUtil;

import java.sql.*;

public class ThinClient {
    public static void main(String[] args) throws SQLException {
        //1、本质是把sql发给一个服务，这个服务处理后，再发给hbase
        String url = ThinClientUtil.getConnectionUrl("hadoop102",8765);

        //2、获取链接
        Connection connection = DriverManager.getConnection(url);

        //3、编译sql语句
        PreparedStatement preparedStatement = connection.prepareStatement("select * from student");

        //4、执行语句
        ResultSet resultSet = preparedStatement.executeQuery();

        //5、输出结果
        while (resultSet.next()){
            System.out.println(resultSet.getString(1) + ":" + resultSet.getString(2) + ":" + resultSet.getString(3));
        }

        //6、关闭资源
        connection.close();
    }
}
